package com.fjnldx.ks.mapper;

import com.fjnldx.ks.pojo.domain.ProcessSheet;
import com.fjnldx.ks.pojo.domain.User;
import com.fjnldx.ks.pojo.mesDoMain.*;
import com.fjnldx.ks.pojo.request.GydReq2;
import com.fjnldx.ks.pojo.request.GydReq3;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Component;

import java.util.List;


@Component
@Mapper
public interface MesForthMapper {
    // 查询是否存在该工艺单编号
    @Select("select * from process_sheet where specnum=#{specnum}")
    ProcessSheet findSpecNum(String specnum);
    //插入工艺单数据
    @Insert("insert into process_sheet(specnum,version,org,workshop,equipment,vart_code,cur_vart,ori_vart,machine,name,up_time,gongxu,status) values(#{specnum},#{version},#{org},#{workshop},#{equipment},#{vartCode},#{curVart},#{oriVart},#{machine},#{name},#{upTime},#{gongxu},#{status})")
    int insertProcessSheet(ProcessSheet processSheet);
    //更新工艺单数据
    @Update("update process_sheet set version=#{version},org=#{org},workshop=#{workshop},equipment=#{equipment},vart_code=#{vartCode},cur_vart=#{curVart},ori_vart=#{oriVart},machine=#{machine},name=#{name},up_time=#{upTime},gongxu=#{gongxu},status=#{status} where specnum=#{specnum}")
    int updateGyd(ProcessSheet processSheet);
    // 查询工艺单模板并条1
    @Select(" <script> SELECT *"+
            "from mes_gyd_bingtiao1" +
            " WHERE " +
            "1=1"+
            " <if test=\"pz!=null\">and pz = #{pz} </if> "+
            " limit #{page},#{size}</script>")
    public List<MesGydBingtiao1> getMesGydBingtiao1(GydReq2 gydReq);
    @Select("select count(id) from mes_gyd_bingtiao1")
    Integer getCountMesGydBingtiao1();
    // 查询工艺单模板并条2
    @Select(" <script> SELECT *"+
            "from mes_gyd_bingtiao2" +
            " WHERE " +
            "1=1"+
            " <if test=\"pz!=null\">and pz = #{pz} </if> "+
            " limit #{page},#{size}</script>")
    public List<MesGydBingtiao2> getMesGydBingtiao2(GydReq2 gydReq);
    @Select("select count(id) from mes_gyd_bingtiao2")
    Integer getCountMesGydBingtiao2();
    // 查询工艺单模板并条3
    @Select(" <script> SELECT *"+
            "from mes_gyd_bingtiao3" +
            " WHERE " +
            "1=1"+
            " <if test=\"pz!=null\">and pz = #{pz} </if> "+
            " limit #{page},#{size}</script>")
    public List<MesGydBingtiao3> getMesGydBingtiao3(GydReq2 gydReq);
    @Select("select count(id) from mes_gyd_bingtiao3")
    Integer getCountMesGydBingtiao3();
    // 查询工艺单模板粗纱
    @Select(" <script> SELECT *"+
            "from mes_gyd_chusha" +
            " WHERE " +
            "1=1"+
            " <if test=\"pz!=null\">and pz = #{pz} </if> "+
            " limit #{page},#{size}</script>")
    public List<MesGydChusha> getMesGydChuSha(GydReq2 gydReq);
    @Select("select count(id) from mes_gyd_bingtiao3")
    Integer getCountMesGydChuSha();
    // 查询工艺单模板梳棉
    @Select(" <script> SELECT * "+
            "from mes_gyd_shumian" +
            " WHERE " +
            "1=1"+
            " <if test=\"pz!=null\">and pz = #{pz} </if> "+
            " limit #{page},#{size}</script>")
    public List<MesGydShumian> getMesShumian(GydReq2 gydReq);
    @Select("select count(id) from mes_gyd_shumian")
    Integer getCountMesGydShumian();
    // 查询工艺单模板梳棉
    @Select(" <script> SELECT *"+
            "from mes_gyd_xisha" +
            " WHERE " +
            "1=1"+
            " <if test=\"pz!=null\">and pz = #{pz} </if> "+
            " limit #{page},#{size}</script>")
    public List<MesGydXisha> getMesXisha(GydReq2 gydReq);
    @Select("select count(id) from mes_gyd_xisha")
    Integer getCountMesGydXisha();
    //插入工艺单并条1数据
    @Insert("insert into mes_gyd_bingtiao1(pz,time,stgz,gdl,gdhcl,gz,qzytdc,gyfc,qsdyab,zlyrs,qtzlcd,qtzllc,zqsyef,zqsygh,zjxqsbs,hqsbs,gj,lbk,bhs,dc,cs) values(#{pz},#{time},#{stgz},#{gdl},#{gdhcl},#{gz},#{qzytdc},#{gyfc},#{qsdyab},#{zlyrs},#{qtzlcd},#{qtzllc},#{zqsyef},#{zqsygh},#{zjxqsbs},#{hqsbs},#{gj},#{lbk},#{bhs},#{dc},#{cs})")
    int insertMesGydBingTiao1(MesGydBingtiao1 mesGydBingtiao1);
    //插入工艺单并条2数据
    @Insert("insert into mes_gyd_bingtiao2(pz,time,gdl,gdhcl,gz,qzytdc,gyfc,qsdyab,zlyrs,qtzlcd,qtzllc,zqsyef,zqsygh,zjxqsbs,hqsbs,gj,lbk,bhs,dc,cs) values(#{pz},#{time},#{gdl},#{gdhcl},#{gz},#{qzytdc},#{gyfc},#{qsdyab},#{zlyrs},#{qtzlcd},#{qtzllc},#{zqsyef},#{zqsygh},#{zjxqsbs},#{hqsbs},#{gj},#{lbk},#{bhs},#{dc},#{cs})")
    int insertMesGydBingTiao2(MesGydBingtiao2 mesGydBingtiao2);
    //插入工艺单并条3数据
    @Insert("insert into mes_gyd_bingtiao3(pz,time,gdl,qzytdc,gyfc,qsdyab,zlyrs,qtzlcd,qtzllc,zqsyef,zqsygh,zjxqsbs,hqsbs,gj,lbk,bhs,dc,cs) values(#{pz},#{time},#{gdl},#{qzytdc},#{gyfc},#{qsdyab},#{zlyrs},#{qtzlcd},#{qtzllc},#{zqsyef},#{zqsygh},#{zjxqsbs},#{hqsbs},#{gj},#{lbk},#{bhs},#{dc},#{cs})")
    int insertMesGydBingTiao3(MesGydBingtiao3 mesGydBingtiao3);
    //插入工艺单粗纱数据
    @Insert("INSERT INTO mes_gyd_chusha(pz, time, wrmtgdl, csgdl, zlqsbs, gdhc, gdl, xsd, ds, dc, ksjscd, mrsdmrcd, dssd, cxjd, llgj, gjk, qzyhqy, zqs, hqsbs, nd, nxs) VALUES (#{pz},#{time},#{wrmtgdl},#{csgdl},#{zlqsbs},#{gdhc},#{gdl},#{xsd},#{ds},#{dc},#{ksjscd},#{mrsdmrcd},#{dssd},#{cxjd},#{llgj},#{gjk},#{qzyhqy},#{zqs},#{hqsbs},#{nd},#{nxs})")
    int insertMesGydChusha(MesGydChusha mesGydChusha);
    //插入工艺单梳棉数据
    @Insert("INSERT INTO mes_gyd_shumian(pz, time, cj, gdl, gdhcl, gzm, xsd, cksd, xlsd, mdpckp, gbsdy, gbdjpl, gbsd, dfdjpl, dfzs, zly, ctxs, dfxs, kskzs) VALUES (#{pz},#{time},#{cj},#{gdl},#{gdhcl},#{gzm},#{xsd},#{cksd},#{xlsd},#{mdpckp},#{gbsdy},#{gbdjpl},#{gbsd},#{dfdjpl},#{dfzs},#{zly},#{ctxs},#{dfxs},#{kskzs})")
    int insertMesGydShumian(MesGydShumian mesGydShumian);
    //插入工艺单细纱数据
    @Insert("INSERT INTO mes_gyd_xisha( pz, cj, time, csdlnd, csnd, gdhc, sjhs, djpzzp, cs, dc, qzydy, zjxqsbs, hqsy, hqsbs, nddyzb, gj, cxyzb, ccs, gsq, ylb, wgq, gjk, pkyd, qzdyl, sjnd, nxs, tcl) VALUES (#{pz},#{cj},#{time},#{csdlnd},#{csnd},#{gdhc},#{sjhs},#{djpzzp},#{cs},#{dc},#{qzydy},#{zjxqsbs},#{hqsy},#{hqsbs},#{nddyzb},#{gj},#{cxyzb},#{ccs},#{gsq},#{ylb},#{wgq},#{gjk},#{pkyd},#{qzdyl},#{sjnd},#{nxs},#{tcl})")
    int insertMesGydXisha(MesGydXisha mesGydXisha);
    // 删除工艺单并条1
    @Delete("DELETE FROM mes_gyd_bingtiao1 WHERE id=#{id}")
    int deleteMesGydBingTiao1(GydReq3 gydReq3);
    // 删除工艺单并条2
    @Delete("DELETE FROM mes_gyd_bingtiao2 WHERE id=#{id}")
    int deleteMesGydBingTiao2(GydReq3 gydReq3);
    // 删除工艺单并条3
    @Delete("DELETE FROM mes_gyd_bingtiao3 WHERE id=#{id}")
    int deleteMesGydBingTiao3(GydReq3 gydReq3);
    // 删除工艺单粗纱
    @Delete("DELETE FROM mes_gyd_chusha WHERE id=#{id}")
    int deleteMesGydCuSha(GydReq3 gydReq3);
    // 删除工艺单细纱
    @Delete("DELETE FROM mes_gyd_xisha WHERE id=#{id}")
    int deleteMesGydXiSha(GydReq3 gydReq3);
    // 删除工艺单梳棉
    @Delete("DELETE FROM mes_gyd_shumian WHERE id=#{id}")
    int deleteMesGydShuMian(GydReq3 gydReq3);
    //更新工艺单并条1
    @Update("update mes_gyd_bingtiao1 set pz=#{pz},time=#{time},stgz=#{stgz},gdl=#{gdl},gdhcl=#{gdhcl},gz=#{gz},qzytdc=#{qzytdc},gyfc=#{gyfc},qsdyab=#{qsdyab},zlyrs=#{zlyrs},qtzlcd=#{qtzlcd},qtzllc=#{qtzllc},zqsyef=#{zqsyef},zqsygh=#{zqsygh},zjxqsbs=#{zjxqsbs},hqsbs=#{hqsbs},gj=#{gj},lbk=#{lbk},bhs=#{bhs},dc=#{dc},cs=#{cs} where id=#{id}")
    int updateMesGydBingTiao1(MesGydBingtiao1 mesGydBingtiao1);
    //更新工艺单并条2
    @Update("update mes_gyd_bingtiao2 set pz=#{pz},time=#{time},gdl=#{gdl},gdhcl=#{gdhcl},gz=#{gz},qzytdc=#{qzytdc},gyfc=#{gyfc},qsdyab=#{qsdyab},zlyrs=#{zlyrs},qtzlcd=#{qtzlcd},qtzllc=#{qtzllc},zqsyef=#{zqsyef},zqsygh=#{zqsygh},zjxqsbs=#{zjxqsbs},hqsbs=#{hqsbs},gj=#{gj},lbk=#{lbk},bhs=#{bhs},dc=#{dc},cs=#{cs} where id=#{id}")
    int updateMesGydBingTiao2(MesGydBingtiao2 mesGydBingtiao2);
    //更新工艺单并条3
    @Update("update mes_gyd_bingtiao3 set pz=#{pz},time=#{time},gdl=#{gdl},qzytdc=#{qzytdc},gyfc=#{gyfc},qsdyab=#{qsdyab},zlyrs=#{zlyrs},qtzlcd=#{qtzlcd},qtzllc=#{qtzllc},zqsyef=#{zqsyef},zqsygh=#{zqsygh},zjxqsbs=#{zjxqsbs},hqsbs=#{hqsbs},gj=#{gj},lbk=#{lbk},bhs=#{bhs},dc=#{dc},cs=#{cs} where id=#{id}")
    int updateMesGydBingTiao3(MesGydBingtiao3 mesGydBingtiao3);
    //更新工艺单粗纱
    @Update("update mes_gyd_chusha set pz=#{pz},time=#{time},wrmtgdl=#{wrmtgdl},csgdl=#{csgdl},zlqsbs=#{zlqsbs},gdhc=#{gdhc},gdl=#{gdl},xsd=#{xsd},ds=#{ds},dc=#{dc},ksjscd=#{ksjscd},mrsdmrcd=#{mrsdmrcd},dssd=#{dssd},cxjd=#{cxjd},llgj=#{llgj},gjk=#{gjk},qzyhqy=#{qzyhqy},zqs=#{zqs},hqsbs=#{hqsbs},nd=#{nd},nxs=#{nxs} where id=#{id}")
    int updateMesGydCuSha(MesGydChusha mesGydChusha);
    //更新工艺单梳棉
    @Update("update mes_gyd_shumian set pz=#{pz},time=#{time},cj=#{cj},gdl=#{gdl},gdhcl=#{gdhcl},gzm=#{gzm},xsd=#{xsd},cksd=#{cksd},xlsd=#{xlsd},mdpckp=#{mdpckp},gbsdy=#{gbsdy},gbdjpl=#{gbdjpl},gbsd=#{gbsd},dfdjpl=#{dfdjpl},dfzs=#{dfzs},zly=#{zly},ctxs=#{ctxs},dfxs=#{dfxs},kskzs=#{kskzs} where id=#{id}")
    int updateMesGydShuMian(MesGydShumian mesGydShumian);
    //更新工艺单细纱
    @Update("update mes_gyd_xisha set pz=#{pz},cj=#{cj},time=#{time},csdlnd=#{csdlnd},csnd=#{csnd},gdhc=#{gdhc},sjhs=#{sjhs},djpzzp=#{djpzzp},cs=#{cs},dc=#{dc},qzydy=#{qzydy},zjxqsbs=#{zjxqsbs},hqsy=#{hqsy},hqsbs=#{hqsbs},nddyzb=#{nddyzb},gj=#{gj},cxyzb=#{cxyzb},ccs=#{ccs},gsq=#{gsq},ylb=#{ylb},wgq=#{wgq},gjk=#{gjk},pkyd=#{pkyd},qzdyl=#{qzdyl},sjnd=#{sjnd},nxs=#{nxs},tcl=#{tcl} where id=#{id}")
    int updateMesGydXiSha(MesGydXisha mesGydXisha);
    //======================================================Excel导入=================
    // 查询是否存在该细纱生产编号
    @Select("select * from mes_scjh_xisha where scjhbh=#{scjhbh}")
    MesScjhXisha findScbhXisha(String scjhbh);
    //插入细纱生产计划表
    @Insert("insert into mes_scjh_xisha(scjhbh,cj,btjth,btts,bttc,csjth,csts,xsjth,xsts,xstct,xsclt,xspz,ds,dl,cs,xiaolv,de,sygs,sygsts,zgsts,time) values(#{scjhbh},#{cj},#{btjth},#{btts},#{bttc},#{csjth},#{csts},#{xsjth},#{xsts},#{xstct},#{xsclt},#{xspz},#{ds},#{dl},#{cs},#{xiaolv},#{de},#{sygs},#{sygsts},#{zgsts},#{time})")
    int insertScjhXiSha(MesScjhXisha mesScjhXisha);
    //更新细纱生产计划表
    @Update("update mes_scjh_xisha set scjhbh=#{scjhbh},cj=#{cj},btjth=#{btjth},btts=#{btts},bttc=#{bttc},csjth=#{csjth},csts=#{csts},xsjth=#{xsjth},xsjth=#{xsjth},xsts=#{xsts},xstct=#{xstct},xsclt=#{xsclt},xspz=#{xspz},ds=#{ds},dl=#{dl},cs=#{cs},xiaolv=#{xiaolv},de=#{de},sygs=#{sygs},sygsts=#{sygsts},zgsts=#{zgsts},time=#{time} where scjhbh=#{scjhbh}")
    int updateScjhXiSha(MesScjhXisha mesScjhXisha);

    // 查询是否存在该络筒生产编号
    @Select("select * from mes_scjh_luotong where scjhbh=#{scjhbh}")
    MesScjhLuotong findScjhLuoTong(String scjhbh);
    //插入络筒生产计划表
    @Insert("insert into mes_scjh_luotong(scjhbh,cj,chph,lzpz,jth,jakt,jbkt,jckt,jhts,ds,dl,cs,xiaolv,de,llcl,xsjhcl,lsjhcl,jhcllt,jat,ybt,bct,time) values(#{scjhbh},#{cj},#{chph},#{lzpz},#{jth},#{jakt},#{jbkt},#{jckt},#{jhts},#{ds},#{dl},#{cs},#{xiaolv},#{de},#{llcl},#{xsjhcl},#{lsjhcl},#{jhcllt},#{jat},#{ybt},#{bct},#{time})")
    int insertScjhLuoTong(MesScjhLuotong mesScjhLuotong);
    //更新络筒生产计划表
    @Update("update mes_scjh_luotong set scjhbh=#{scjhbh},cj=#{cj},chph=#{chph},lzpz=#{lzpz},jth=#{jth},jakt=#{jakt},jbkt=#{jbkt},jckt=#{jckt},jhts=#{jhts},ds=#{ds},dl=#{dl},cs=#{cs},xiaolv=#{xiaolv},de=#{de},llcl=#{llcl},xsjhcl=#{xsjhcl},lsjhcl=#{lsjhcl},jhcllt=#{jhcllt},jat=#{jat},ybt=#{ybt},bct=#{bct},time=#{time} where scjhbh=#{scjhbh}")
    int updateScjhLuoTong(MesScjhLuotong mesScjhLuotong);

    // 查询是否存在该粗纱生产编号-废弃
    @Select("select * from mes_scjh_cusha where scjhbh=#{scjhbh}")
    MesScjhCusha findScjhCuSha(String scjhbh);
    //插入粗纱生产计划表-废弃
    @Insert("insert into mes_scjh_cusha(scjhbh,cj,gongxu,qfpz,xh,cjtz,jhts,jakt,ybkt,bckt,qk,ds,dl,cs,xiaolv,de,xsjhcl,jat,ybt,time) values(#{scjhbh},#{cj},#{gongxu},#{qfpz},#{xh},#{cjtz},#{jhts},#{jakt},#{ybkt},#{bckt},#{qk},#{ds},#{dl},#{cs},#{xiaolv},#{de},#{xsjhcl},#{jat},#{ybt},#{time})")
    int insertScjhCuSha(MesScjhCusha mesScjhCusha);
    //更新粗纱生产计划表--废弃
    @Update("update mes_scjh_cusha set scjhbh=#{scjhbh},cj=#{cj},gongxu=#{gongxu},qfpz=#{qfpz},xh=#{xh},cjtz=#{cjtz},jhts=#{jhts},jakt=#{jakt},ybkt=#{ybkt},bckt=#{bckt},qk=#{qk},ds=#{ds},dl=#{dl} ,cs=#{cs} ,xiaolv=#{xiaolv} ,de=#{de} ,xsjhcl=#{xsjhcl} ,jat=#{jat} ,ybt=#{ybt},time=#{time} where scjhbh=#{scjhbh}")
    int updateScjhCuSha(MesScjhCusha mesScjhCusha);
    // 查询是否存在该粗纱生产编号
    @Select("select * from user")
    User findUser();
}
